#include "detaildialog.h"
#include "ui_detaildialog.h"

DetailDialog::DetailDialog(QWidget *parent,mode m) :
    QDialog(parent),
    ui(new Ui::DetailDialog)
{
    ui->setupUi(this);
    this->setWindowTitle("诊断结果");

    //患者隐藏编辑框
    if(!m){
        ui->widget_edit->hide();
        ui->textEdit_suggestion->setDisabled(true);
    }

    //设置详细信息的图片显示
    QPixmap pic(":/res/fail.png");
    pic=pic.scaled(ui->label_displayPic->size(),Qt::KeepAspectRatio,Qt::SmoothTransformation);
    ui->label_displayPic->setPixmap(pic);

    for(int i=0;i<7;i++){
        //根据概率范围设置字体颜色
        QTableWidgetItem *item=ui->tableWidget->item(i,1);
        double curData=item->text().toDouble();
        if(curData==0.0)
            item->setForeground(Qt::darkGreen);
        else if(curData<=0.5)
            item->setForeground(Qt::darkYellow);
        else
            item->setForeground(Qt::red);
    }
}

DetailDialog::~DetailDialog()
{
    delete ui;
}

void DetailDialog::on_pushButton_clicked()
{
    ui->textEdit_suggestion->setText("");
}
